package com.mylogistics.common.controller;

import com.mylogistics.common.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * QQ邮箱验证码
 */
@RestController
@RequestMapping("code")
public class CodeValidateController {
    @Autowired
    CodeService codeService;

    @GetMapping("send")
    public String send(String principal){
        codeService.createAndSendCode(principal);
        return "验证码发送成功";
    }

    @PostMapping("verify")
    public Boolean verifyCode(String principal, String code){
        return codeService.verifyCode(principal,code);
    }
}

